﻿using B.S.Ingredients.APIRead.Application.Command.Products;
using B.S.Ingredients.Domain;
using B.S.Ingredients.ErrorCode;
using B.S.Ingredients.Infartructrue.Enit;
using B.S.Ingredients.Infartructrue.Interfaces;
using MediatR;

namespace B.S.Ingredients.APIRead.Application.CommandHandler.ProductHandler
{
    public class ProdictNameQueryCommandHandler : IRequestHandler<ProdictNameQueryCommand, APIResult<List<ProduciNameClass>>>
    {
        public ProdictNameQueryCommandHandler(IBaseRepository<ProduciNameClass> producinameRepository)
        {
            ProducinameRepository = producinameRepository;
        }

        public IBaseRepository<ProduciNameClass> ProducinameRepository { get; }

        public async Task<APIResult<List<ProduciNameClass>>> Handle(ProdictNameQueryCommand request, CancellationToken cancellationToken)
        {
            var path = ProducinameRepository.GetAll().ToList();
         
            return new APIResult<List<ProduciNameClass>>()
            {
                Code = ResultCode.success,
                Mag = "",
                Data = path
            };
        }
    }
}
